#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

vector<int> sortArrayByParityII(vector<int>& nums) {
    vector<int> res(nums.size());
    int p1 = 0, p2 = 1;
    for (int i = 0; i < nums.size(); i++)
    {
        if (nums[i] % 2 == 0)
        {
            res[p1] = nums[i];
            p1 += 2;
        }
        else
        {
            res[p2] = nums[i];
            p2 += 2;
        }
    }
    return res;
}

vector<vector<int>> construct2DArray(vector<int>& original, int m, int n) {
    if (m * n != original.size()) return vector<vector<int>>();
    vector<vector<int>> vv(m, vector<int>(n));

    int r = 0, c = 0;
    for (int i = 0; i < original.size(); i++)
    {
        vv[r][c++] = original[i];
        if (c >= n)
        {
            r++;
            c = 0;
        }
    }
    return vv;
}

vector<string> buildArray(vector<int>& target, int n) {
    vector<string> res;
    int pos = 0;
    for (int i = 1; i <= n; i++)
    {
        res.push_back("Push");
        if (target[pos] != i)
        {
            res.push_back("Pop");
        }
        else
            pos++;
        if (pos >= target.size())
            break;
    }
    return res;
}

class A
{
public:
    void foo()
    {
        cout << 1;
    }
    virtual void fun()
    {
        cout << 2;
    }
};

class B :public A
{
public:
    void foo()
    {
        cout << 3;
    }
    void fun()
    {
        cout << 4;
    }
};

//int main()
//{
//    A a;
//    B b;
//    A* p = &a;
//    p->foo();
//    p->fun();
//    p = &b;
//    p->foo();
//    p->fun();
//    A* ptr = (A*)&b;
//    ptr->foo();
//    ptr->fun();
//
//    return 0;
//}

class CParent
{
public: virtual void Intro()
{
    printf("I'm a Parent, "); Hobby();
};
virtual void Hobby()
{
    printf("I like football!");
}
};
class CChild : public CParent {
public: virtual void Intro()
{
    printf("I'm a Child, "); Hobby();
};
virtual void Hobby()
{
    printf("I like basketball!\n");
}
};

int main()
{
    CChild* pChild = new CChild();
    CParent* pParent = (CParent*)pChild;
    pParent->Intro();
    return 0;
}